package wwl.lsf.imitateMybatis;

import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.stereotype.Component;
import wwl.lsf.repository.LetCodeMapper;

//@Component
public class MyImportBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar {

  @Override
  public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
      BeanDefinitionRegistry registry, BeanNameGenerator importBeanNameGenerator) {

    BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder
        .genericBeanDefinition(LetCodeMapper.class);

    GenericBeanDefinition beanDefinition = (GenericBeanDefinition) beanDefinitionBuilder
        .getBeanDefinition();
    beanDefinition.getConstructorArgumentValues()
        .addGenericArgumentValue("wwl.lsf.repository.LetCodeMapper");
    beanDefinition.setBeanClass(MyFactoryBean.class);

    registry.registerBeanDefinition("wwlrrr", beanDefinition);

  }
}
